package bishi.s360;

import java.util.*;

public class demo2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        int[][] targets = new int[k][2];
        for(int i = 0;i < k;i++) {
            targets[i][0] = in.nextInt();
            targets[i][1] = in.nextInt();
        }
        int max = 0;
        for(int dx = -n;dx <= n;dx++) {
            for(int dy = -m;dy <= m;dy++) {
                if(dx == 0 &&dy == 0) continue;
                int num = test(Math.abs(dx),Math.abs(dy));
                int sdx = dx / num;
                int sdy =dy/num;
                if(sdx > 0 || (sdx == 0 && sdy > 0)) {
                    int count = 0;
                    for(int[] demo : targets) {
                        if(onPath(demo[0],demo[1],sdx,sdy,n,m)) count++;

                    }
                    max = Math.max(max,count);
                }
            }
        }
        System.out.println(max);
    }

    static  boolean onPath(int x,int y,int dx,int dy,int n,int m) {
        for(int t = 0;t < 2*n*m;t++) {
            int px = (t*dx) %(2 * n);
            int py = (t*dy) %(2*m);
            if(px < 0) px += 2*n;
            if(py < 0) py += 2*m;
            if(px == x && py ==y) return true;
            if(px > n && py >m) break;
        }
        return false;
    }
    static int test(int a ,int b) {
        if(b == 0) {
            return a;
        }else {
            test(b,a%b);
        }
        return -1;
    }
}
